﻿@inherits DictsBase

<EditPage Id="dict" FixedHeader="@FixedHeader" TItem="Bootstrap.Security.BootstrapDict" SubmitModalTitle="字典编辑窗口" QueryModel="QueryModel" OnQuery="Query" OnAdd="Add" OnDelete="Delete" OnSave="Save" OnResetSearch="ResetSearch">
    <QueryBody>
        <LgbInputText ColumnClass="col-12" @bind-Value="@context.Category" maxlength="50" />
        <Select ColumnClass="col-12" Items="QueryDefine" TItem="int" @bind-Value="@context.Define" />
        <LgbInputText ColumnClass="col-12" @bind-Value="@context.Name" maxlength="50" />
    </QueryBody>
    <TableInfoTemplate>
        <ConditionComponent>
            <div class="alert alert-danger" role="alert">
                <span>演示系统禁止修改系统使用字典配置项</span>
            </div>
        </ConditionComponent>
    </TableInfoTemplate>
    <TableHeader>
        <LgbTableHeader TItem="string" @bind-Value="@context.Category" Sort="true"></LgbTableHeader>
        <LgbTableHeader TItem="string" @bind-Value="@context.Name" Sort="true"></LgbTableHeader>
        <LgbTableHeader TItem="string" @bind-Value="@context.Code" Sort="true"></LgbTableHeader>
        <LgbTableHeader TItem="int" @bind-Value="@context.Define" Sort="true"></LgbTableHeader>
    </TableHeader>
    <RowTemplate>
        <td>@context.Category</td>
        <td>@context.Name</td>
        <td>@context.Code</td>
        <td>@(DefineItems.FirstOrDefault(d => d.Value == context.Define.ToString())?.Text ?? "-")</td>
    </RowTemplate>
    <EditTemplate>
        <div class="row">
            <LgbInputText @bind-Value="@context.Category" placeholder="不可为空，50字以内" maxlength="50">
                <RequiredValidator />
                <StringLengthValidator Length="50" />
            </LgbInputText>
            <Select Items="DefineItems" TItem="int" @bind-Value="@context.Define"></Select>
            <LgbInputText @bind-Value="@context.Name" placeholder="不可为空，50字以内" maxlength="50">
                <RequiredValidator />
                <StringLengthValidator Length="50" />
            </LgbInputText>
            <LgbInputText @bind-Value="@context.Code" placeholder="不可为空，2000字以内" maxlength="2000">
                <RequiredValidator />
                <StringLengthValidator Length="2000" />
            </LgbInputText>
        </div>
    </EditTemplate>
</EditPage>
